<?php

class m111102_064948_employee_certificate extends CDbMigration {
	public function safeUp() {
		$this
			->createTable('erp_employee_certificate',
				array(
					'id' => 'pk',
					'employeeId' => 'int',
					'grantDate' => 'date',
					'summary' => 'string',
					'note' => 'string',
					'typeId' => 'int',
					'imagePath' => 'string',
					'thumbPath' => 'string',
					'createTime' => 'datetime',
					'createUserId' => 'int',
					'updateTime' => 'datetime',
					'updateUserId' => 'int',
				));
		$this
			->createIndex("employee_certificate_create_user_id", 'erp_employee_certificate',
				'createUserId');
		$this
			->addForeignKey('fk_employee_certificate_create_user_id', 'erp_employee_certificate',
				'createUserId', 'erp_user', 'id', 'SET NULL', 'CASCADE');
		$this
			->createIndex("employee_certificate_update_user_id", 'erp_employee_certificate',
				'updateUserId');
		$this
			->addForeignKey('fk_employee_certificate_update_user_id', 'erp_employee_certificate',
				'updateUserId', 'erp_user', 'id', 'SET NULL', 'CASCADE');
		$this
			->createIndex("employee_certificate_employee_id", 'erp_employee_certificate',
				'employeeId');
		$this
			->addForeignKey('fk_employee_certificate_employee_id', 'erp_employee_certificate',
				'employeeId', 'erp_employee', 'id', 'CASCADE', 'CASCADE');
	}

	public function safeDown() {
		$this->dropTable('erp_employee_certificate');
	}
}
